﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ArticleListing.ascx.cs" Inherits="ArticleListing" %>

<asp:GridView ID="gvwArticles" runat="server" SkinID="Grid"  
    AllowPaging="True" AutoGenerateColumns="False"
   DataKeyNames="ID" DataSourceID="objArticles" ShowHeader="False"
    OnRowCommand="gvwArticles_RowCommand" Width="100%">
   <Columns>
      <asp:TemplateField HeaderText="Article List (including those not yet published)">
         <HeaderStyle HorizontalAlign="Left" />
         <ItemTemplate>
            <table width="100%" cellpadding="2" cellspacing="2" style="border-bottom:solid 1px #d4d0c8">
                <tr>
                    <td >
                        <span runat="server" id="spanImageUrl" Visible='<%# Eval("IsShowImage") %>'>
                            <div style="padding:2px; border:solid 1px #d4d0c8;" >
                                <asp:Image ID="Image1" ImageUrl='<%# Eval("ImageUrl") %>' runat="server" Width="100px" Height="80px" Visible='<%# Eval("IsShowImage") %>' />                        
                            </div>
                        </span>                            
                    </td>
                    <td style="width:100%" valign="top" align="left">
                            <table cellpadding="0" cellspacing="0" style="width: 100%;">
                                <tr>
                                     <td>               
                               <div class="titleProduct">
                               <asp:HyperLink runat="server" class="titleProduct" ID="lnkTitle" Text='<%# Eval("Title") %>'
                                  NavigateUrl='<%# "~/ShowArticle.aspx?ID=" + Eval("ID") %>'/> 
                                  <asp:Image ID="Image2" ImageUrl="~/Images/imgNew.gif" runat="server" Visible='<%# Eval("IsNew") %>' />
                               </div>
                               <asp:Label runat="server" ID="Literal1" Text='<%# " Ngày đăng : " + Eval("ReleaseDate", "{0:d}") %>' Font-Italic="true" Font-Size="Smaller" />
                               <asp:Label runat="server" ID="Literal2" Text='<%# ", Lượt xem : " + Eval("ViewCount") %>' Font-Italic="true" Font-Size="Smaller" />                                                           
                            </td>
                            <td style="text-align: right;width:20px;">
                               <asp:Panel runat="server" ID="panEditArticle" Visible='<%# UserCanEdit %>'>
                               <asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Cập nhật"
                                  NavigateUrl='<%# "~/Admin/AddEditArticle.aspx?ID=" + Eval("ID") %>' ImageUrl="~/Images/Edit.gif" />
                               </asp:Panel>
                            </td>
                            <td style="text-align: right;width:20px;">
                               <asp:Panel runat="server" ID="panDeleteArticle" Visible='<%# UserCanEdit %>'>
                               <asp:ImageButton runat="server" ID="ImageButton1" ImageUrl="~/Images/Delete.gif"
                                  CommandName="Delete" AlternateText="Xóa"
                                  OnClientClick="if (confirm('Bạn có chắc muốn xóa bài này ?') == false) return false;" />
                               </asp:Panel>
                            </td>
                                </tr>
                            </table>
                        <asp:Literal runat="server" ID="lblAbstract" Text='<%# Eval("Abstract") %>' />
                        <div style="width:100%; text-align:right;">
                            <asp:HyperLink runat="server" ID="HyperLink1" Text="Chi tiết..." ForeColor="#d4d0c8" Font-Size="Small"
                            NavigateUrl='<%# "~/ShowArticle.aspx?ID=" + Eval("ID") %>'/> 
                        </div>
                    </td>
                </tr>
            </table>   
         </ItemTemplate>         
      </asp:TemplateField>
   </Columns>   
   <EmptyDataTemplate><b>Chưa có bài viết nào.</b></EmptyDataTemplate>   
</asp:GridView>
<p>
<asp:Literal runat="server" ID="lblPageSizePicker"><small><b>Số bài một trang : </b></small></asp:Literal>
<asp:DropDownList ID="ddlArticlesPerPage" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlArticlesPerPage_SelectedIndexChanged">
   <asp:ListItem Value="5">5</asp:ListItem>
   <asp:ListItem Value="10" Selected="True">10</asp:ListItem>
   <asp:ListItem Value="25">25</asp:ListItem>
   <asp:ListItem Value="50">50</asp:ListItem>   
   <asp:ListItem Value="100">100</asp:ListItem>
</asp:DropDownList>
</p>
<asp:ObjectDataSource ID="objArticles" runat="server" DeleteMethod="DeleteArticle"
   SelectMethod="ListArticles" SelectCountMethod="Articles_GetArticleCount" 
   TypeName="BLL.Article.Article">
   <DeleteParameters>
      <asp:Parameter Name="id" Type="Int32" />
   </DeleteParameters>
   <SelectParameters>
      <asp:Parameter DefaultValue="true" Name="publishedOnly" Type="Boolean" />
      <asp:Parameter Name="categoryID" Type="Int32" DefaultValue="1" />
   </SelectParameters>
</asp:ObjectDataSource>
